import React from 'react'
import { ConfigProvider } from '@douyinfe/semi-ui';
import zh_CN from '@douyinfe/semi-ui/lib/es/locale/source/zh_CN';
import en_GB from '@douyinfe/semi-ui/lib/es/locale/source/en_GB';
import { createContext, useContext, useState } from 'react';

const BaseConfigContext = createContext<any>(null);
export function useBaseConfig() {
  return useContext(BaseConfigContext);
}
export const BaseConfigConsumer = BaseConfigContext.Consumer;

function BaseConfigProvider({ children }: any) {
  const [locale, setLocale] = useState(zh_CN);
  const value = {
    setLocale,
  };

  return (
    <BaseConfigContext.Provider value={value}>
      <ConfigProvider locale={locale}>{children}</ConfigProvider>
    </BaseConfigContext.Provider>
  );
}

export default BaseConfigProvider;